package com.example.hm_dtfkz.ui.activity;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.webkit.WebSettings;

import androidx.viewbinding.ViewBinding;

import com.android.base.ui.base.VBBaseActivity;
import com.android.base.util.ActivityClickUtil;
import com.example.hm_dtfkz.R;
import com.example.hm_dtfkz.databinding.ActivityIntroduceBinding;

/**
 * FileName: IntroduceActivity
 * Author: admin
 * Date: 2021/11/8 10:56
 * Description:
 */
public class IntroduceActivity extends VBBaseActivity implements View.OnClickListener {

    private ActivityIntroduceBinding introduceBinding;

    public static void startActivity(Activity activity) {
        Intent intent = new Intent(activity, IntroduceActivity.class);
        activity.startActivity(intent);
    }

    @Override
    protected ViewBinding getViewBinding() {
        setTitleBackground(BG_WHITE);
        return introduceBinding = ActivityIntroduceBinding.inflate(getLayoutInflater());
    }

    @SuppressLint("SetJavaScriptEnabled")
    @Override
    public void initView() {
        super.initView();
        ActivityClickUtil.getInstance().clear();
        introduceBinding.tvTitle.setText("玩法介绍");

        WebSettings settings = introduceBinding.wvIntroduce.getSettings();
        // 设置缩放
        settings.setBuiltInZoomControls(false);
        // 使页面适应用户屏幕
        settings.setUseWideViewPort(true);
        settings.setLoadWithOverviewMode(true);
        settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        // 开启JavaScript
        settings.setJavaScriptEnabled(true);
        introduceBinding.wvIntroduce.setVerticalScrollBarEnabled(false);//隐藏垂直滚动条
        introduceBinding.wvIntroduce.loadUrl("file:///android_asset/cow_introduce.html");
    }

    @Override
    public void initLister() {
        super.initLister();
        introduceBinding.imgBack.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (ActivityClickUtil.getInstance().isFastClick()) {
            //防止用户快速点击
            return;
        }
        if (v.getId() == R.id.imgBack) {
            finish();
        }
    }
}
